package app.service.impl;

import app.dao.DaoUr;
import app.domain.Ur;
import app.service.ServiceUr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ServiceUrImpl implements ServiceUr {
    @Autowired
    private DaoUr daoUr;

    //保存方法
    @CachePut(key = "#p0.roleId", value = "my-redis-cache2")
    @Override
    public void insert(Ur ur) {
        daoUr.save(ur);
    }

    //根据用户id查询用户与角色的关系
    @Override
    public Ur getByUserId(Integer userId) {
        return daoUr.getByUserId(userId);
    }
}
